<template>
	<view class="box">
		<view class="info" v-for="item in infolist" :key="item._id">
			<workinfo @deletezp="deletezp" :item="item" :isclose="true"></workinfo>
		</view>
		<u-modal @cancel="cancel" @confirm="confirm" :showCancelButton="true" confirmText="确认删除" :show="immediate"
			:title="title" :content='content'></u-modal>
	<view class="nomore" v-if="nomore">
		<text>暂未发布</text>
	</view>
	</view>
</template>

<script>
	const db = uniCloud.database()
	export default {
		data() {
			return {
				user_id: '',
				infolist: [],
				immediate: false,
				title: "你将要删除",
				content: '',
				delete_id: '',
				nomore:false
			};
		},
		onLoad() {
			this.user_id = uniCloud.getCurrentUserInfo().uid
			this.getinfolist()
			console.log('来是否打开饭盒你说的看见反函数打开链接')
		},
		methods: {
			cancel() {
				this.immediate = false
			},
			//删除我的招聘信息
			confirm() {
				uni.showLoading({
					title: "删除中"
				})
				db.collection('recruitment').where({
					'_id': this.delete_id
				}).remove().then(res => {
					uni.hideLoading()
					this.getfilters()
					uni.showToast({
						title: "删除成功"
					})
					this.immediate = false
				
					console.log(res, "删除陈工")
				})

			},
			//删除
			deletezp(e) {
				this.immediate = true
				this.content = e[1]
				this.delete_id = e[0]
				console.log(e)
			},
			//获取我的招聘信息
			async getinfolist() {

				let reTemp = db.collection("recruitment").where({
					"user_id": this.user_id,
				}).field(
					'user_id,company_id,look_person,company_id,user_work,industry,criticism_title,study,money,work_impreance,position_desc,publish_date,company_name,company_nums'
				).getTemp()
				let userTemp = db.collection("uni-id-users").field('_id,nickname,avatar').getTemp()
				await db.collection(reTemp, userTemp).get().then(
					res => {
						console.log('广告', res)
						if (res.result.data.length == 0) {
							this.nodata2 = true
						}
						this.infolist = res.result.data
						
					})
			},
			//无感删除
			getfilters() {
				console.log('执行了')
				this.infolist = this.infolist.filter(item => {
					return item._id != this.delete_id
				})
				if(this.infolist==0){
					this.nomore=true
				}
			}
		}
	}
</script>

<style lang="scss">
	.nomore{
			height: 30vh;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 60rpx;
			color: #F2E8CF;
		}
</style>
<style>
	page{
		background-color: #10255b;
	}
</style>